package com.zhuss.opus.opus;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.opus.opus.CreamOpusBo;
import com.zhuss.bean.bo.opus.opus.CreateOpusBo;
import com.zhuss.bean.bo.opus.opus.DeleteOpusBo;
import com.zhuss.bean.bo.opus.opus.UpdateOpusBo;
import com.zhuss.bean.bo.opus.opus.wechat.CollectOpusBo;
import com.zhuss.bean.bo.opus.opus.wechat.DelTopicOpusBo;
import com.zhuss.bean.bo.opus.opus.wechat.ForwardOpusBo;
import com.zhuss.bean.bo.opus.opus.wechat.RecommendOpusBo;
import com.zhuss.bean.bo.opus.opus.wechat.ThumbOpusBo;
import com.zhuss.bean.bo.opus.opus.wechat.TopicOpusBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;

/**
 * opus操作service（基本操作）
 * @author zhushanshuo
 * @Date 2020-02-05 15:59
 *
 */
@Component("opusOperateService")
public class OpusOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("opusCreate")
	private Processor<Object, CreateOpusBo> opusCreate;
	
	@Autowired
	@Qualifier("opusUpdate")
	private Processor<Object, UpdateOpusBo> opusUpdate;
	
	@Autowired
	@Qualifier("opusDelete")
	private Processor<Object, DeleteOpusBo> opusDelete;
	
	@Autowired
	@Qualifier("opusThumb")
	private Processor<Object, ThumbOpusBo> opusThumb;
	
	@Autowired
	@Qualifier("opusCollect")
	private Processor<Object, CollectOpusBo> opusCollect;
	
	@Autowired
	@Qualifier("opusForward")
	private Processor<Object, ForwardOpusBo> opusForward;
	
	@Autowired
	@Qualifier("opusRecommend")
	private Processor<Object, RecommendOpusBo> opusRecommend;
	
	@Autowired
	@Qualifier("opusCream")
	private Processor<Object, CreamOpusBo> opusCream;
	
	@Autowired
	@Qualifier("opusTopic")
	private Processor<Object, TopicOpusBo> opusTopic;
	
	@Autowired
	@Qualifier("opusDelThumb")
	private Processor<Object, ThumbOpusBo> opusDelThumb;
	
	@Autowired
	@Qualifier("opusDelCollect")
	private Processor<Object, CollectOpusBo> opusDelCollect;
	
	@Autowired
	@Qualifier("opusDelForward")
	private Processor<Object, ForwardOpusBo> opusDelForward;
	
	@Autowired
	@Qualifier("opusDelTopic")
	private Processor<Object, DelTopicOpusBo> opusDelTopic;
	
	@Autowired
	@Qualifier("opusDelRecommend")
	private Processor<Object, RecommendOpusBo> opusDelRecommend;
	
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws WpsException {
		
		CreateOpusBo bo = (CreateOpusBo) param;
		
		opusCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws WpsException {
    	
		UpdateOpusBo bo = (UpdateOpusBo) param;
		
		opusUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws WpsException {
		
		DeleteOpusBo bo = (DeleteOpusBo) param;
		
		opusDelete.process(bo);
		
		return null;
	}
	
	/**
	 * 点赞
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void thumb(Object param) throws WpsException {
		
		ThumbOpusBo bo = (ThumbOpusBo) param;
		
		opusThumb.process(bo);
		
		return null;
	}
	
	/**
	 * 收藏
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void collect(Object param) throws WpsException {
		
		CollectOpusBo bo = (CollectOpusBo) param;
		
		opusCollect.process(bo);
		
		return null;
	}
	
	/**
	 * 转发
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void forward(Object param) throws WpsException {
		
		ForwardOpusBo bo = (ForwardOpusBo) param;
		
		opusForward.process(bo);
		
		return null;
	}
	
	/**
	 * 推荐
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void recommend(Object param) throws WpsException {
		
		RecommendOpusBo bo = (RecommendOpusBo) param;
		
		opusRecommend.process(bo);
		
		return null;
	}
	
	/**
	 * 评论
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void topic(Object param) throws WpsException {
		
		TopicOpusBo bo = (TopicOpusBo) param;
		
		opusTopic.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 点赞
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delThumb(Object param) throws WpsException {
		
		ThumbOpusBo bo = (ThumbOpusBo) param;
		
		opusDelThumb.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 收藏
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delCollect(Object param) throws WpsException {
		
		CollectOpusBo bo = (CollectOpusBo) param;
		
		opusDelCollect.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 转发
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delForward(Object param) throws WpsException {
		
		ForwardOpusBo bo = (ForwardOpusBo) param;
		
		opusDelForward.process(bo);
		
		return null;
	}
	
	/**
	 * 删
	 * 推荐
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delRecommend(Object param) throws WpsException {
		
		RecommendOpusBo bo = (RecommendOpusBo) param;
		
		opusDelRecommend.process(bo);
		
		return null;
	}
	
	/**
	 * 删
	 * 评论
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delTopic(Object param) throws WpsException {
		
		DelTopicOpusBo bo = (DelTopicOpusBo) param;
		
		opusDelTopic.process(bo);
		
		return null;
	}
	
	/**
	 * 优选
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void cream(Object param) throws WpsException {
		
		CreamOpusBo bo = (CreamOpusBo) param;
		
		opusCream.process(bo);
		
		return null;
	}
	
}

